package com.viphuli.http.handler;

import android.view.View;

import com.viphuli.common.Constants;
import com.viphuli.common.Constants.PayType;
import com.viphuli.common.Constants.TicketType;
import com.viphuli.fragment.PurchaseOrderInfoFragment;
import com.viphuli.http.bean.page.PurchaseOrderInfoPage;
import com.viphuli.http.bean.part.PurchaseOrder;
import com.viphuli.http.bean.part.PurchasePayTicket;

public class PurchaseOrderInfoResponseHandler extends MyBaseHttpResponseHandler<PurchaseOrderInfoFragment, PurchaseOrderInfoPage> {

	@Override
	public void deal() {
		PurchaseOrder order = page.getOrder();

		//填充数据
		caller.getIdText().setText(order.getOrderId());//订单ID
		caller.getStatusText().setText(order.status());
		caller.getTimeText().setText(order.createTimeMinute());
		caller.getServiceTimeText().setText(order.serviceTimeMinute());
		caller.getDurationText().setText(order.serviceDuration());
		caller.getNameText().setText(order.getName());
		caller.getPayText().setText(order.price());//显示价格
		caller.getSiteText().setText(order.address());//地址：位址+详细地址
		caller.getPhoneText().setText(order.getTel());
		caller.getRemarkText().setText(order.getRemark());

		//支付信息
		int payType = order.getPayType();

		caller.getPayPriceText().setText(order.payPrice());

		if (PayType.aliPay.getPayType() == payType) {

			caller.getPayPriceTitleText().setText(PayType.aliPay.getName() + "：");

		} else if (PayType.weichatPay.getPayType() == payType) {

			caller.getPayPriceTitleText().setText(PayType.weichatPay.getName() + "：");

		} else if (PayType.offlinePay.getPayType() == payType) {
			caller.getPayPriceTitleText().setText(PayType.offlinePay.getName() + "：");

		}

		//优惠券
		PurchasePayTicket ticket = order.getTicket();
		if (ticket != null) {
			caller.getTicketLayout().setVisibility(View.VISIBLE);
			caller.getTicketText().setText(ticket.getName());

			if (TicketType.money.getType() == ticket.getTicketType()) {

				caller.getTicketTitleText().setText(TicketType.money.getName() + "：");

			} else if (TicketType.discount.getType() == ticket.getTicketType()) {

				caller.getTicketTitleText().setText(TicketType.discount.getName() + "：");

			} else {

				caller.getTicketTitleText().setText(TicketType.other.getName() + "：");

			}

		} else {
			caller.getTicketLayout().setVisibility(View.GONE);
		}

		//评价入口
		if (Constants.ORDER_STATUS_WAIT_COMMENT == order.getStatus()) {//待评论
			caller.getCommentBtn().setVisibility(View.VISIBLE);
		} else {
			caller.getCommentBtn().setVisibility(View.GONE);
		}
	}
}
